package priv.mill.xml;
import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class MyFilter implements BeanPostProcessor {

	private static final Logger logger = Logger.getLogger(MyFilter.class);

	public Object postProcessAfterInitialization(Object bean, String name)
			throws BeansException {
		if(name.equals("person")){
			Person person=(Person) bean;
			person.setName("白骨精");
		}
		return bean;
	}

	public Object postProcessBeforeInitialization(Object bean, String name)
			throws BeansException {
		System.out.println("Before");
		if(name.equals("person")){
			Person person=(Person) bean;
			person.setName("猪八戒");
		}
		return bean;
	}
}
